﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace WiMo.Games
{
    public struct Vector3
    {
        private float _x;
        public float X
        {
            get { return _x; }
            set{_x = value;}
        }

        private float _y;
        public float Y
        {
            get { return _y; }
            set { _y = value; }
        }

        private float _z;
        public float Z
        {
            get { return _z; }
            set { _z = value; }
        }

        public Vector3(float x, float y, float z)
        {
            _x = x;
            _y = y;
            _z = z;
        }

        public float Magnitude
        {
            get { return (float)Math.Sqrt((double)(X * X + Y * Y + Z * Z)); }
        }

        public override string ToString()
        {
            return string.Format("X={0} Y={1} Z={2}", Math.Round(X, 4), Math.Round(Y, 4), Math.Round(Z, 4));
        }

        public Vector3 Normalize()
        {
            return Scale(1 / Magnitude);
        }

        public Vector3 Scale(float scale)
        {
            var ret = this;
            ret.X *= scale;
            ret.Y *= scale;
            ret.Z *= scale;
            return ret;
        }

    }
}
